package pl.enigmatic.parser.xml;

import pl.enigmatic.util.XML;
import pl.enigmatic.parser.string.Converter;
import pl.enigmatic.parser.string.EnumConverter;


@SuppressWarnings({ "rawtypes" })
public final class EnumParser<E extends Enum> extends Parser<E> {

	/** value converter */
	private final EnumConverter<E> converter;

	EnumParser(final Class<E> enumClass) {
		super(enumClass, false);
		converter = (EnumConverter<E>) Converter.createDefaultConverter(enumClass);
	}

	@Override
	public E parse(final ParsingInfo<E> info) {
		return converter.convert(XML.getText(info.getNode()));
	}
}
